package com.yuma.rabbitmq.work.main;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.yuma.rabbitmq.work.util.ConnectionUtil;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Productor {
    private static final String QUEUE_NAME = "work_queue";

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = ConnectionUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(QUEUE_NAME, false, false, false, null);

        // 循环发送消息
        for (int i = 1; i <= 10; i++){
            channel.basicPublish("", QUEUE_NAME, null, ("hello world" + i).getBytes());
        }

        channel.close();
        connection.close();
    }
}
